package fem2.jlinalg;

import inf.jlinalg.IMatrixReadOnly;

/**
 * class for identity matrix
 * 
 * @author hbui
 * 
 */
public class IdentityMatrix implements IMatrixReadOnly {

	private static final long serialVersionUID = 1L;

	private int n;

	public IdentityMatrix(int n) {
		this.n = n;
	}

	@Override
	public double get(int i, int j) {
		if (i == j) {
			return 1.0;
		} else {
			return 0.0;
		}
	}

	@Override
	public int getColumnCount() {
		return n;
	}

	@Override
	public int getRowCount() {
		return n;
	}

	public Object clone() {
		return new IdentityMatrix(n);
	}
}
